



/*
 * Created on 16-07-2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package utiles.SQL;

/**
 * @author Virtual Dark Priest
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.sql.DataSource;

import javax.swing.JOptionPane;
import utiles.configuration.ConfigurationParametersManager;

/**
 * <p>
 * Implementa una fuente de datos que es utilizada por los DAO
 * </p>
 * 
 */
/*
public class SimpleDataSource implements DataSource {
    private static final String DRIVER_CLASS_NAME_PARAMETER = "DataSource/driverClassName";

    private static final String URL_PARAMETER = "DataSource/url";

    private static final String USER_PARAMETER = "DataSource/user";

    private static final String PASSWORD_PARAMETER = "DataSource/password";

    private static String url;

    private static String user;

    private static String password;

    static {
        try {
            /* Leer los parametros de configuracion */
  /*          String driverClassName = ConfigurationParametersManager.getParameter(DRIVER_CLASS_NAME_PARAMETER);
            url = ConfigurationParametersManager.getParameter(URL_PARAMETER);
            user = ConfigurationParametersManager.getParameter(USER_PARAMETER);
            password = ConfigurationParametersManager.getParameter(PASSWORD_PARAMETER);

            /* Cargando el Driver */
    /*        Class.forName(driverClassName);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } // static

    
        public Connection getConnection() throws SQLException {
        Connection c = null;
         try {
         c= DriverManager.getConnection(url, user, password);
        //System.out.print(c);
       
         }
         catch (Exception e) {
             
           if(c==null){
            //JOptionPane.showMe       
               System.out.print(e.toString());
               System.exit(0);
               
        }
        }
        return c;
    }
    

    public Connection getConnection(String username, String password) throws SQLException {

        throw new UnsupportedOperationException("Not implemented");
    }

    public PrintWriter getLogWriter() throws SQLException {
        throw new UnsupportedOperationException("Not implemented");
    }

    public void setLogWriter(PrintWriter out) throws SQLException {
        throw new UnsupportedOperationException("Not implemented");
    }

    public void setLoginTimeout(int seconds) throws SQLException {
        throw new UnsupportedOperationException("Not implemented");
    }

    public int getLoginTimeout() throws SQLException {
        throw new UnsupportedOperationException("Not implemented");
    }

	public boolean isWrapperFor(Class arg0) throws SQLException {
		// TODO Auto-generated method stub
		return false;
	}

	public Object unwrap(Class arg0) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}
}*/



/*aqui comienza el cambio de codigo*/

	
/*
 * Created on 16-07-2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
//package utiles.SQL;

/**
 * @author Virtual Dark Priest
 *
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.sql.DataSource;

import javax.swing.JOptionPane;
import utiles.configuration.ConfigurationParametersManager;

/**
 * <p>
 * Implementa una fuente de datos que es utilizada por los DAO
 * </p>
 *
 */
public class SimpleDataSource implements DataSource {

    private static final String DRIVER_CLASS_NAME_PARAMETER = "DataSource/driverClassName";
    private static final String URL_PARAMETER = "DataSource/url";
    private static final String USER_PARAMETER = "DataSource/user";
    private static final String PASSWORD_PARAMETER = "DataSource/password";
    
    private static String url;
    private static String user;
    private static String password;
    private static String url1;
    private static String user1;
    private static String password1;
   

    static {
        try {
            /* Leer los parametros de configuracion */
            String driverClassName = ConfigurationParametersManager.getParameter(DRIVER_CLASS_NAME_PARAMETER);
            url = ConfigurationParametersManager.getParameter(URL_PARAMETER);
            user = ConfigurationParametersManager.getParameter(USER_PARAMETER);
            password = ConfigurationParametersManager.getParameter(PASSWORD_PARAMETER);

          

            /* Cargando el Driver */
            Class.forName(driverClassName);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } // static


    public Connection getConnection() throws SQLException {
        Connection c = null;
       

        try {
            c = DriverManager.getConnection(url, user, password);
        //System.out.print(c);

        } catch (Exception e) {

            
                System.out.print(e.toString());
                System.exit(0);

            }
        
        return c;
    }

    public Connection getConnection(String username, String password) throws SQLException {

        throw new UnsupportedOperationException("Not implemented");
    }

    public PrintWriter getLogWriter() throws SQLException {
        throw new UnsupportedOperationException("Not implemented");
    }

    public void setLogWriter(PrintWriter out) throws SQLException {
        throw new UnsupportedOperationException("Not implemented");
    }

    public void setLoginTimeout(int seconds) throws SQLException {
        throw new UnsupportedOperationException("Not implemented");
    }

    public int getLoginTimeout() throws SQLException {
        throw new UnsupportedOperationException("Not implemented");
    }

    public boolean isWrapperFor(Class arg0) throws SQLException {
        // TODO Auto-generated method stub
        return false;
    }

    public Object unwrap(Class arg0) throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }
}